<?php
require_once(dirname(__FILE__)."/../../libs/login/login.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../../libs/string/pager.php");
require_once(dirname(__FILE__)."/../../admin/libs/member_class.php");
$mb=new member();
$pg=new pager();
$mc= new libstr();
$lg=new login();
$lg->checklogin("admin_member");//检验是否登录
//执行操作 使用js提交的
if($mc->Ismp($_POST["cz"])!=""){
if($_POST["cz"]==-3){
	$mb->member_del($_POST["items"]);
}else{
	$mb->updateisshow($_POST["items"],$_POST["cz"]);
}

}


//获得列表参数 使用js提交的
$string="*";//获得项
$userid="";
$userno="";
$username="";
if($_GET["keyname"]=="userid"){
	$userid=$_GET["keyvalue"];
}
if($_GET["keyname"]=="username"){
	$username=$_GET["keyvalue"];
}
$sex="";
$email="";
$shouji="";
$address="";
$isshow="";
if($mc->Ismp($_GET["isshow"]!=""))$isshow=$_GET["isshow"];
$starttime=$_GET["starttime"];//注册开始时间
$endtime=$_GET["endtime"];//注册结束时间
$order="id";
$sj="desc";
if($mc->Ismp($_GET["sj"]!=""))$sj=$_GET["sj"];
$pagesize=10;
if($mc->Ismp($_GET["pagesize"]!=""))$pagesize=$_GET["pagesize"];
$page=1;
if($mc->Ismp($_GET["page"]!=""))$page=$_GET["page"];
$mbs=$mb->memberlist($string,$userid,$userno,$username,$sex,$email,$shouji,$address,$isshow,$starttime,$endtime,$order,$sj,$pagesize,$page);


//分页

$totalcount_xiaoquan=$mbs[0]["totalcount"];
$totalcount=$totalcount_xiaoquan;
$pg->isre=false;
	$pindex="";

	$getpp=$pg->fsarr($pg->fstr($pindex,$totalcount,$pagesize,6,""));
	$ptxt="";
	foreach ($getpp as $pagers)
	{
		if($pagers["color"]!="true")
		{
			$ptxt .="<li ><a href='".$pagers["url"]."' >".$pagers["index"]."</a></li>";
		}else
		{
			$ptxt .="<li class=\"ea\"><a href='javascript:;' >".$pagers["index"]."</a></li>";
		}
	}
	if($totalcount>0){
		$pagetext="<li> <a href='".$pg->next($pg->pp($pindex,$totalcount,$pagesize,"",""))."'><img src='../images/leftjt.jpg' width='10' height='11' /></a></li> ".$ptxt."  <li><a href='".$pg->next($pg->np($pindex,$totalcount,$pagesize,"",""))."'><img src='../images/yightjt.jpg' width='10' height='11' /></a></li>";
	}
	if($pagesize>=$totalcount){$pagetext="";}
$path="用户列表";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理系统</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script src="../../plug/calendar/WdatePicker.js"></script>
<script type="text/javascript">
//搜素用户
function mbsearch(){
	if($("#starttime").val()!="" && $("#endtime").val()!=""){
	if($("#starttime").val()>$("#endtime").val()){
		alert("时间选择不正确！");
		return;
	}
	}
	$("#mbsearch").submit();
	
	
}
//全选操作
function checkall(){
	
   if($("#checkedAll").attr("checked") == true){ //check all
  $("input[name='items[]']").each(function(){
     $(this).attr("checked",true);
    });

   }else{
 $("input[name='items[]']").each(function(){
     $(this).attr("checked",false);
	     });
   }
}
//执行操作多个
function zhixing(){
	if($("input[type=checkbox][name='items[]']:checked").length==0){
		alert("您还没选中任何用户！");
		return;
	}
if(confirm("您确定要执行所选项？")){
	$("#czform").submit();
	return;
	}
}



</script>
</head>
<body style="background:#fff"> 

<div class="content">
    <div class="right">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        	<tr>
                <td width="100%" height="24" class="top_head">&nbsp;</td>
            </tr>
            <tr>
              <td valign="top">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="1%" align="right"  height="45">&nbsp;</td>
                      <td width="99%" >
                       <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="55%" style="padding-left:20px;padding-top:10px;"><img src="../images/head.gif" width="13" height="11"><b><?php echo $path;?></b><a href='member_add.php' style=" margin-left:20px; text-decoration:underline;">新增用户</a></td>
                          <td width="45%" align="right">&nbsp;</td>
                        </tr>
                      </table>
                      </td>
                    </tr>
                  </table>
              </td>
           </tr>
           <tr>
        <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="bg">
          <tr >
            <td valign="middle"  style=" padding:5px 0 5px 0;" >
            	<table width="92%"  border="0" cellspacing="0" align="center">
                	<tr>
                    	<td width="20%" align="left">
                        	<Div class="xuanxiang">
                                <input type="submit" name="button" id="button" value="全部用户" onclick="location.href='member_list.php'" <?php if($_GET["isshow"]==""){?> class="active" <?php }?>/>
                                <input type="submit" name="button" id="button" value="回收站" onclick="location.href='member_list.php?isshow=-2'"<?php if($_GET["isshow"]=="-2"){?>class="active"  <?php }?> />
                             </Div>
                        </td>
                    	<td width="80%" align="right">
                        	 <!--<div class="xuanze2">
                             <form method="GET" action="" id="mbsearch">
                             	<select name="keyname">
                                    <option value="userid"  <?php if($mc->Ismp($_GET['keyname'])=="userid"){?>selected<?php }?>>用户账号</option>
                                    <option value="username"  <?php if($mc->Ismp($_GET['keyname'])=="username"){?>selected<?php }?>>用户名</option>
                                </select>
                                <input name="keyvalue" type="text" value="<?php echo $_GET["keyvalue"]?>"/>
                              
                                <select name="regtime">
                               		 <option value="regtime">注册时间</option>
                                 </select><font>时间</font>
                                 <span>
                                 	<input name="starttime" type="text"  onfocus="WdatePicker({el:'starttime'})" id="starttime" value="<?php if($mc->Ismp($_GET['starttime'])!=""){echo $_GET['starttime']; }?>"/></span><font>-</font>
                                 <Span><input name="endtime" type="text" onfocus="WdatePicker({el:'endtime'})" id="endtime" value="<?php if($mc->Ismp($_GET['endtime'])!=""){echo $_GET['endtime']; }?>"/></Span>
                                 <Span>
                                  <select name="sj"> 
                                      <option value="desc" <?php if($mc->Ismp($_GET['sj'])=="desc"){?>selected<?php }?>>降序</option>
                                       <option value="asc" <?php if($mc->Ismp($_GET['sj'])=="asc"){?>selected<?php }?>>升序</option>
                                    </select>
                                 </Span>
                                <Span>
                                    <select name="pagesize">
                                      <option value="10">显示</option>
                                        <option value="15" <?php if($mc->Ismp($_GET['pagesize'])=="15"){?>selected<?php }?>>15条</option>
                                        <option value="20" <?php if($mc->Ismp($_GET['pagesize'])=="20"){?>selected<?php }?>>20条</option>
                                        <option value="30" <?php if($mc->Ismp($_GET['pagesize'])=="30"){?>selected<?php }?>>30条</option>
                                    </select>
                                </Span>
                                <bdo><input name="search" type="submit" value="搜 索" onclick="mbsearch()" /></bdo>
                              </form>
                            </div>-->
                        </td>
                    </tr>
                </table>
             </td>
          </tr>

        </table>
       </td>
      </tr>
      <tr>
         <td valign="middle" align="center" >
            	<table width="92%"   border="1px" bordercolor="#ccc" cellspacing="0px" style="border-collapse:collapse">
                  <thead align="center" bgcolor="#EEEEEE">
                    <tr>
                    <th  width="3%" height="28" align="left"  >&nbsp;</th>
                	<th height="30" align="left" style="padding-left:1%; ">账号</th>
                    <th width="8%" height="30" align="center">用户名</th>
                    <th width="7%" height="30" align="center">级别</th> 
                    <th width="10%" height="30" align="center"><strong>邮箱</strong></th>
                    <th width="11%" align="center"><strong>注册时间</strong></th>
                    <!--<th width="5%" align="center">登录次数</th>
                    <th width="9%" align="center">状态</th>-->
                    <th width="11%" colspan="2" align="center">操作</th>
                </tr>
              </thead>
              <tbody>
              <form action="" method="POST" id="czform">
           <?php if(count($mbs)>0){ ?>   
              <?php for($i=0;$i<count($mbs);$i++){?>
              	<?php if($mbs[$i]["userid"]!='admin'){?> <!--不显示admin-->
              	<tr>
                	<td width="2%" height="28"align="center"><input name="items[]" type="checkbox" value="<?php echo $mbs[$i]["id"];?>" /></td>
                	<td width="13%" align="left"><?php echo $mbs[$i]["userid"];?></td>
                    <td height="28"align="center"><?php echo $mbs[$i]["username"];?></td>
                    <td height="28"align="center"><?php echo $mb->getclassname($mbs[$i]["rootid"]);?></td>
                    <td height="28"align="center"><?php echo $mbs[$i]["email"];?></td>
                    <td height="28"align="center"><?php echo $mc->gettime($mbs[$i]["regtime"]);?></td>
                    <!--<td height="28"align="center"><?php echo $mbs[$i]["hit"];?></td>
                    <td height="28"align="center"><?php echo $mb->showzhuangtai($mbs[$i]["isshow"]);?></td>-->
                    <td height="28"colspan="2" align="center">
              	    <Bdo><input type="button" name="button5" id="button5" value="修改" onclick="location.href='member_edit.php?userno=<?php echo $mbs[$i]["userno"];?>'"/></Bdo>
           	   </td>
                </tr>
              	<?php }} }else{?>
              <tr align="center" bgcolor="#FFFFFF">
               
                    <td height="30" colspan="10" align="center">对不起，暂时找不到相关用户！</td>
                    
                </tr>
                <?php }?>
                <?php if($pagetext!=""){?>
                 <tr align="center" bgcolor="#FFFFFF">
                    <td height="40" align="center">&nbsp;</td>
                    <td height="40" align="left">&nbsp;</td>
                    <td height="40">&nbsp;</td>
                    <td height="40">&nbsp;</td>
                    <td height="50" colspan="8" align="right" valign="middle">
                    <ul>
                     <?php echo $pagetext;?>
                    </ul></td>
                    </tr>
                    <?php }?>
                   <tr align="center" bgcolor="#FFFFFF">
                  <td height="30" align="center"><input type="checkbox" value="checkbox" id="checkedAll" name="checkedAll" onclick="checkall()"></td>
              	  <td height="30" align="left" colspan="8">
              
              	    <select name="cz" id="select">
              	    <!--<option value="1">已审核</option>
              	    <option  value="0" >未审核</option>-->
              	    <option  value="-2">删除</option>
              	    <option value="-3">彻底删除</option>
              	    <option value="1">还原回收</option>
            	      </select> <input type="button" name="czbtn" id="czbtn" value="执行" onclick="zhixing()" class="czbtn"/></td>
              	  </tr>
              	  </form>
              </tbody>
        </table>
        </td>
      </tr>
    </table>
    
    </div>
</div>
</body>
</html>